package com.example.yunxiappbackend.config;

import com.example.yunxiappbackend.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.io.FileNotFoundException;
import java.sql.SQLException;

@Slf4j
@ControllerAdvice(annotations = {Controller.class, RestController.class})
@ResponseBody
public class GlobalExceptionHandler{
    @ExceptionHandler(FileNotFoundException.class)
    public Result<String> FileNotFoundException(){
        return Result.error("找不到指定文件！");
    }

    @ExceptionHandler(SQLException.class)
    public Result<String> SQLException(){
        return Result.error("数据库异常！请检查输入的数据");
    }
}
